'use strict';

/**
 * @ngdoc directive
 * @name jgappApp.directive:logList
 * @description
 * # logList
 */
angular.module('jgappApp')
    .directive('logList', ["Util", "openApi","OpenFile", function(Util, openApi,OpenFile) {
        return {
            scope: {
                logResult: "="
            },
            replace: true,
            template: '<div class="log-list task-detail-section mt10" ng-show="logResult.length>0">' +
                '<div class="log-title">审批记录</div>' +
                '<div class="log-content fs14" ng-repeat="item in logResult">' +
                '<div class="log-item lh20">' +
                '<div class="log-item-result {{item.className}}">' +
                '<p class="c0 fs16">{{item.assigneeName}} [{{item.name_}}] </p>' +
                '<p><span ng-bind-html="item.aduitDesc" class="c0"></span></p>' +
                '<p class="c0" ng-if="item.taskDefinitionKey">快递单号:<span class="c-succ celled" ng-click="checkDefinitionKey(item.taskDefinitionKey)">{{item.taskDefinitionKey}}</span></p>' +
                '<p class="c0" ng-if="item.description_">附件:<span class="c-succ celled" ng-click="goDetail(item.description_)">{{item.description_}}</span></p>' +
                '<div class="flex"><p class="w30">{{item.operationResult}}</p><p class="tr c9 w70">{{item.endTime}}</p></div></div>' +
                '</div>' +
                '</div>',
            restrict: 'AE',
            link: function postLink(scope, element, attrs) {
                // element.text('this is the logList directive');
                scope.checkDefinitionKey = function(id) {
                    Util.openExpress(id);
                }
                scope.goDetail = function(fileData) {
                    if (Util.isImg(fileData)) {
                        scope.src = openApi.showimg + "?fileName=" + fileData;
                        Util.showFile(scope);
                    } else if (Util.isFile(fileData)) {
                        OpenFile.open(fileData)
                    } else {
                        Util.Toast("移动端不支持预览")
                    }
                };
                scope.closefile = function() {
                    Util.hideFile();
                }
            }
        };
    }]);
